package alt.djudge.frontend.server.gui;

import java.lang.reflect.Field;

import alt.djudge.frontend.server.datatypes.ContestEntry;

class Full extends SubmissionsDataFormatSettings
{
	public Full()
	{
		showAll();
	}
}

class ShortIP extends SubmissionsDataFormatSettings
{
	public ShortIP()
	{
		hideAll();
		showIP = true;
		showSubmissionTime = true;
		showState = true;
		showJudgement = true;
		showSubmissionId = true;
	}
}


public class SubmissionsDataFormatSettings
{
	public static final SubmissionsDataFormatSettings FULL = new Full();
	
	public static final SubmissionsDataFormatSettings SHORT_IP = new ShortIP();	
	
	public boolean showSubmissionId = true;
	
	public boolean showContestName = true;
	
	public boolean showUserName = true;
	
	public boolean showSubmissionTime = true;
	
	public boolean showContestTime = true;
	
	public boolean showProblemName = true;
	
	public boolean showLanguageName = true;
	
	public boolean showSorceSize = true;
	
	public boolean showJudgement = true;
	
	public boolean showMaxMemory = true;
	
	public boolean showMaxOutput = true;
	
	public boolean showScore = true;
	
	public boolean showWrongTestNumber = true;
	
	public boolean showMaxTime = true;
	
	public boolean showState = true;
	
	public boolean showIP = true;
	
	public SubmissionsDataFormatSettings()
	{
		// TODO Auto-generated constructor stub
	}
	
	public SubmissionsDataFormatSettings(ContestEntry c)
	{
		showContestName = false;
		// TODO: fix this
		showContestTime = false;
		showIP = false;
		showJudgement = true;
		showLanguageName = true;
		showMaxMemory = c.getShowMaxMemory();
		showMaxOutput = c.getShowMaxOutput();
		showMaxTime = c.getShowMaxTime();
		showProblemName = true;
		showScore = c.getShowScore();
		showSorceSize = true;
		showState = true;
		showSubmissionId = true;
		showSubmissionTime = true;
		showUserName = c.getShowFullSubmissions();
		showWrongTestNumber = c.getShowWrongTest();
	}

	public void showAll()
	{
		for (Field f: SubmissionsDataFormatSettings.class.getDeclaredFields())
			if (f.getType().equals(Boolean.class))
		{
			try
			{
				f.setBoolean(this, true);
			}
			catch (Exception e)
			{
				e.printStackTrace();
			}
		}
	}
	
	public void hideAll()
	{
		for (Field f: SubmissionsDataFormatSettings.class.getDeclaredFields())
			if (f.getType().equals(Boolean.class))
		{
			try
			{
				f.setBoolean(this, false);
			}
			catch (Exception e)
			{
				e.printStackTrace();
			}
		}
	}
}
